package com.ruoyi.parcel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.parcel.domain.EOrderDetails;
import com.ruoyi.parcel.service.IEOrderDetailsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * EOrderDetailsController
 *
 * @author ruoyi
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/parcel/details")
public class EOrderDetailsController extends BaseController
{
    @Autowired
    private IEOrderDetailsService eOrderDetailsService;

    /**
     * 查询EOrderDetails列表
     */
    @RequiresPermissions("parcel:parcel:list")
    @GetMapping("/list")
    public TableDataInfo list(EOrderDetails eOrderDetails)
    {
        startPage();
        List<EOrderDetails> list = eOrderDetailsService.selectEOrderDetailsList(eOrderDetails);
        return getDataTable(list);
    }

    /**
     * 导出EOrderDetails列表
     */
    @RequiresPermissions("parcel:parcel:export")
    @Log(title = "EOrderDetails", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EOrderDetails eOrderDetails)
    {
        List<EOrderDetails> list = eOrderDetailsService.selectEOrderDetailsList(eOrderDetails);
        ExcelUtil<EOrderDetails> util = new ExcelUtil<EOrderDetails>(EOrderDetails.class);
        util.exportExcel(response, list, "EOrderDetails数据");
    }

    /**
     * 获取EOrderDetails详细信息
     */
    @RequiresPermissions("parcel:parcel:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eOrderDetailsService.selectEOrderDetailsById(id));
    }

    /**
     * 新增EOrderDetails
     */
    @RequiresPermissions("parcel:parcel:add")
    @Log(title = "EOrderDetails", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EOrderDetails eOrderDetails)
    {
        return toAjax(eOrderDetailsService.insertEOrderDetails(eOrderDetails));
    }

    /**
     * 修改EOrderDetails
     */
    @RequiresPermissions("parcel:parcel:edit")
    @Log(title = "EOrderDetails", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EOrderDetails eOrderDetails)
    {
        return toAjax(eOrderDetailsService.updateEOrderDetails(eOrderDetails));
    }

    /**
     * 删除EOrderDetails
     */
    @RequiresPermissions("parcel:parcel:remove")
    @Log(title = "EOrderDetails", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eOrderDetailsService.deleteEOrderDetailsByIds(ids));
    }
}
